package com.onlyphoto.onlymall.mvp.presenter

import android.content.Context
import com.onlyphoto.onlymall.base.BaseNetworkResponse
import com.onlyphoto.onlymall.base.BaseObserver

import com.onlyphoto.onlymall.mvp.contract.CShippingAddress
import com.onlyphoto.onlymall.mvp.model.MShippingAddressImpl
import com.onlyphoto.onlymall.base.BasePresenter
import com.onlyphoto.onlymall.bean.response.AddressBean


class PShippingAddressImpl(mContext: Context, mView: CShippingAddress.IVShippingAddress) : BasePresenter<CShippingAddress.IVShippingAddress, MShippingAddressImpl>(mContext, mView, MShippingAddressImpl()), CShippingAddress.IPShippingAddress {
    override fun getAddress() {
        mModel.requestUserAddress(object : BaseObserver<ArrayList<AddressBean>>(mContext.get()){
            override fun onSuccess(data: ArrayList<AddressBean>?, msg: String?) {
                mView.updateView()
                if (data == null) {
                    mView.showEmpty()
                }
                mView.getAddressSuccess(data!!)
            }

            override fun onCodeError(t: BaseNetworkResponse<ArrayList<AddressBean>>?) {
            }

            override fun onFailure(e: Throwable?) {
            }

            override fun onRequestStart() {
            }

            override fun onFinally() {
            }

        })
    }
}
